{% extends "base.html" %}
{% load static %}

{% block headjs %}
    <link href="{% static 'datatables/datatables.min.css' %}" rel="stylesheet">



{% endblock %}

{% block content %}
    <div class="row">
        <div class="col-lg">
            <div class="card">
                <div class="card-header">

  <div class="row">
    <div class="col-sm">
      <a type="button" class="btn btn-success" href="{% url 'Kehu_Create' %}">新增客户</a>
        <a type="button" class="btn btn-success" href="{% url 'Kehu_Create' %}">导入</a>
        <a type="button" class="btn btn-success" href="{% url 'Kehu_Create' %}">导出</a>
    </div>
    <div class="col-sm">
      <form class="form-inline my-2 my-lg-0 ml-auto" method="get" action="">
                        <input class="form-control mr-sm-2" type="search" placeholder="模糊搜索" aria-label="Search" name="search">
                        <button class="btn btn-outline-success my-2 my-sm-0" type="submit">搜索</button>
                    </form>
    </div>
    <div class="col-sm">
      One of three columns
    </div>
  </div>
    <div class="row mt-2">
         <div class="form-row align-items-center">
    <div class="col-auto">
      <label class="sr-only" for="inlineFormInput">Name</label>
      <input type="text" class="form-control mb-2" id="search-customer" placeholder="Jane Doe">
    </div>
    <div class="col-auto">
        <label class="sr-only" for="inlineFormInput">Username</label>
      <div class="input-group mb-2">
        <input type="text" class="form-control" id="search-contact" placeholder="Username">
      </div>
    </div>
  </div>
    </div>

        <div class="search-boxes">

        <!-- 为其他字段添加更多搜索框 -->
    </div>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table id="example" class="table table-striped table-bordered dt-container dt-bootstrap4 ">
                            <thead>
                            <tr>
                                <th>客户</th>
                                <th>客户联系人</th>
                                <th>联系电话</th>
                                <th>客户来源</th>
                                <th>报名详情</th>
                                {% if request.user.is_superuser %}<th>客户归属人</th>{% endif %}
                                <th>备注</th>
                                <th>最后跟进记录</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                        <tbody>


                            {% for kehu in kehu_list %}

                                <tr>
                                    <th> <a href="{% url 'Kehu_detail' pk=kehu.id %}">{{ kehu.username }}</a></th>
                                    <th>{{ kehu.name }}</th>
                                    <th>{{ kehu.tel }}</th>
                                    <th>{{ kehu.tg_qudao }}-{{ kehu.tg_qudao.tg_leixing }}</th>
                                    <th>  {% for foo,fook,ifbm in kehu_list_with_last_genjin %}
                                                  {% if kehu == foo %}
                                                       {% if ifbm == 0 %}
                                                        <button type="button" class="btn btn-primary">未报名</button>
                                                          {% else %}
                                                           <a  href="{% url 'Kehu_detail' pk=kehu.id %}#v-pills-profile"> <button type="button" class="btn btn-success">已报名 <span class="badge badge-light badge-pill">{{ ifbm }}</span></button></a>
                                                  {% endif %}
                                                     {% endif %}
                                                {% endfor %}
                                    </th>
                                        {% if request.user.is_superuser %}
   <th> <a href="{% url 'Kehu_detail' pk=kehu.id %}">{{ kehu.admin_user.last_name }}{{ kehu.admin_user.first_name }}</a>
                                    </th>
{% endif %}
                                    <th>
                                       <div class="text-truncate" style="max-width: 200px;">
                                        {{ kehu.beizhu }}
                                        </div>
                                    </th>
                                    <th>
                                        <div class="text-truncate" style="max-width: 200px;">
 {% for foo,fook,ifbm in kehu_list_with_last_genjin %}
                                                  {% if kehu == foo %}
                                                        {{ fook }}
                                                  {% endif %}
   {% endfor %}
                                                </div>
                                    </th>

                                    <th>
                                        <a type="button" class="btn btn-warning" href="{% url 'Kehu_detail' pk=kehu.id %}">详情</a>
                                    </th>


                                </tr>

                            {% endfor %}

                            </tbody>>
                        </table>

                    </div>
                </div>
            </div>

        </div>
    </div>
{% endblock %}

{% block footerjs %}

{% endblock %}
